<template>
  <div>
    <div
      class="wrapper-container"
      style="display: flex; flex-direction: column; width: 100%"
    >
      <div class="search-container">
        <div class="search-container-left">
          <div
            class="search-container-item"
            v-for="(select, index) in selectList"
            :key="index"
          >
            <div v-if="select.type === 'select'" class="box">
              <span v-show="select.name">{{ select.name }}</span>

              <el-select
              @change="chnageVal"
                v-model="select.val"
                style="width: 90px"
                size="mini"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in select.valList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
            <div class="box" v-if="select.type === 'data'">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-date-picker
                v-model="select.val"
                type="date"
                placeholder="选择日期"
                prefix-icon="aaa"
              >
              </el-date-picker>
            </div>
            <div v-if="select.type === 'MultiSelect'" class="box"></div>
            <div v-if="select.type === 'btn'" class="box">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-input
                v-model="select.val"
                placeholder="请输入内容"
              ></el-input>
            </div>
          </div>
          <div class="search-button" style="margin-left: 20px" @click="queryList">
            <img src="../../../../../assets/assessment/icon-search.png" alt="" />
            <span>查询</span>
          </div>
        </div>
      </div>
    </div>
    <div class="tip-text">{{xueqiName}}学期{{db}}上{{courseName}}的学员共{{total}}名:</div>
    <div class="assessment-container">
      <div class="table-container">
        <el-table
          :data="tableData"
          border
          class="table-data"
          row-class-name="row-class"
          cell-class-name="cell-class"
          header-row-class-name="header-row-class"
          header-cell-class-name="header-cell-class"
          style="height: 580px; overflow-y: auto"
        >
          <el-table-column
            label="队别"
            prop="team"
            align="center"
            width="120px"
          >
          </el-table-column>
          <el-table-column prop="grade" label="年级" align="center">
          </el-table-column>
          <el-table-column prop="specialtyClassName" label="专业班次" align="center">
          </el-table-column>
          <el-table-column prop="studentCode" label="学号" align="center">
          </el-table-column>
          <el-table-column prop="studentName" label="姓名" align="center">
          </el-table-column>
          <el-table-column prop="gender" label="性别" align="center">
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="bottom-block" style="display: block;width:calc(100% - 20px);margin: 0 auto;" >
      <div class="text">
        当前共找到{{ total }}条记录,当前显示{{ startPage }}-{{ endPage }}条
      </div>
      <div class="export-button">
        <img src="../../../../../assets/assessment/icon-export.png" alt="" />
        <!-- <span>导出Excel</span> -->
        <download-excel
          class="export-btn"
          :data="tableData"
          :fields="jsonFields"
          type="xls"
          name="制定专业班次学期执行计划.xls"
          style="color: #f3b815"
        >
          &ensp;导出Excel
        </download-excel>
      </div>
    </div>
    <div class="pagination-block">
      <el-pagination
        prev-text="上一页"
        next-text="下一页"
        :page-size="pageSize"
        layout="prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import tablelist from "@/views/comonents/tablelist";
import ButtonItem from "@/components/ButtonItem.vue";

import {hlwxk_xxkcx_ry_cx, queryCommonDB} from "@/api/trainingManagement/place.js";

export default {
  components: {
    tablelist,
    ButtonItem,
  },
  data() {
    return {
      selectList: [
        {
          type: "select",
          name: "队别:",
          val: "",
          valList: [],
        },
      ],
      tableData: [],
      xueqiName: "",
      courseName: "",
      db: "",
      classNo: "",

      total: 0, //总条数
      pageSize: 50, //条数
      startPage: 0, //开始条数
      endPage: 0, //结束条数
      currentPage: 1, //当前页数
    };
  },
  created() {},
  mounted() {
    this.queryCommonDB();
    this.xueqiName = this.$route.query.xueqiName;
    this.classNo = this.$route.query.classNo;
    this.db = this.$route.query.db;
    this.courseName = this.$route.query.courseName;
    this.queryList();
  },
  methods: {
    async queryList() {
      var data = {
          "classNo":this.classNo,
          "db":this.db
      };
      const res = await hlwxk_xxkcx_ry_cx(data);
      if (res.data.code == 200) {
        this.tableData = res.data.data.records;
        this.total = res.data.data.total;
        var length = this.tableData.length;
        this.calculatePage(
          this.pageSize,
          res.data.data.current, length);
      }
    },
    // 计算开始和结束条数
    calculatePage(pageSize, current, length) {
      if (current == 1) {
        if (length != 0) {
          this.startPage = 1;
          this.endPage = length;
        }
      } else {
        this.startPage = pageSize * (current - 1) + 1;
        this.endPage = parseInt(this.startPage)  + parseInt(length) - 1;
      }
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.queryList();
    },
    chnageVal() {
      var db = this.selectList[0].val;
      var dbList = this.selectList[0].valList.filter(item => {
        item.id == db
      })
      this.db = dbList[0].name;
    },
    // 获取队别
    async queryCommonDB() {
      const res = await queryCommonDB();
      if (res.data.code == 200) {
        if (res.data.data.length > 0) {
          this.selectList[0].valList= res.data.data;
          this.selectList[0].val= this.selectList[0].valList[0].id;
        }
      }
    },
  },
  computed: {}, //计算属性
};
</script>
<style lang="less" scoped>
@import "../../../../../styles/text.less";
/deep/ .szjky .el-dialog__body {
  height: 432px;
}
.pagination-block {
  margin-top: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}
</style>
<style lang="less" scoped>
@import "../../../../../styles/supervision.less";

.wrapper-container {
  width: 1711px;
  margin: 0 auto;
}

/deep/ .table-container {
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    /*border-radius: 9px;*/
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.wrapper-container .search-container .search-container-left {
  width: 100%;
  flex-wrap: wrap;
  .search-container-item {
    width: 12%;
    margin-right: 0px;
    .box {
      > span {
        text-align: left;
      }
      display: flex;
      justify-content: space-evenly;
      margin-bottom: 20px;
      align-items: center;
    }
  }
}

/deep/.el-date-editor.el-input {
  width: 110px;
}
/deep/ .el-input--medium {
  width: 110px;
  .el-input__inner {
    height: 28px;
    width: 110px;
    padding: 0px 18px;
  }
}
/deep/ .el-table thead {
  color: #004ca7 !important;
}

.btn {
  margin-top: 271px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 271px;
  .submit {
    width: 84px;
    height: 27px;
    line-height: 8px;
  }
}
.bottom-block {
  // display: flex;
  flex-direction: row;
  justify-content: space-between !important;
  .export-button {
    width: 127px;
    height: 27px;
    background: #fff6ef;
    border: 1px solid #f3b815;
    border-radius: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    > img {
      width: 17px;
      height: 17px;
    }
    > span {
      margin-left: 12px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
  }
  .text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    line-height: 39px;
    color: #004ca7;
  }
}

.search-button {
  width: 77px;
  height: 28px;
  line-height: 28px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  > span {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }
  > img {
    width: 20px;
    height: 20px;
    margin-right: 4px;
  }
}

.mar-lef-2 {
  margin-left: 20px;
}
.undeLine {
  text-decoration: underline;
  cursor: pointer;
}
.btn-caozuo {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 800px;
  margin: 0 auto;
  padding-top: 25px;
}

.tip-text {
    margin: 20px;
    color: #004ca7;
    font-size: 16px;
    font-weight: bold;
}

.assessment-container {
  width: calc(100% - 20px);
  .table-container {
     width: 100%;
  }
}
</style>
